﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/Dialog.Master" AutoEventWireup="true" CodeBehind="AdjustmentDialogBox.aspx.cs" Inherits="Legazpi.Payroll.Web.PopupBoxes.AdjustmentDialogBox" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">

<script type="text/javascript">
    var serviceUrl = '<%=ResolveUrl("~/Webservices/EmployeeWebService.asmx")%>';
    $(document).ready(function () {
        $('#AdjustmentSubmitButton').click(function () {
            if (!$("#dialogForm").valid()) {
                return false;
            }   
            var AdjustmentObj = {
                Id: $('#Id').val(),
                Code: $('#AdjustmentCode').val(),
                Description: $('#Description').val(),
                intAccountType: $('#<%=AccountType.ClientID %> option:selected').val(),
                intAccountSign: $('#<%=AccountSign.ClientID %> option:selected').val()
            };
            var json = JSON.stringify({ adjustmentItem: AdjustmentObj });
            BlockUI.BlockElementLoading("dialog", "Saving...", true, 4);
            $.ajax({
                type: "POST",
                url: serviceUrl + "/AddAdjustment",
                data: json,
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    var response = eval('(' + data.d + ')');
                    if (response.Success) {
                        PopUpDialog.CloseDialog(Adjustment.AdjustmentUpdatePopUpId);
                        Adjustment.SetRowData(response);
                    }
                },
                complete: function () {
                    BlockUI.UnBlockElement("dialog");
                }

            });
        });

        $("#dialogForm").validate({
            rules: {
                AdjustmentCode: "required"
            },
            messages: {
                AdjustmentCode: "Please enter Code"
            }
        });
    });
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Content" runat="server">
            <form id="dialogForm" runat="server">
            <input type="hidden" id="Id" value="<%=Model.Id %>" />            
            <fieldset class="register">
                <legend>Client Details</legend>
                <p>
                    <label for="AdjustmentCode">Code Label:</label>
                    <input type="text" id="AdjustmentCode" name="AdjustmentCode" class="textEntry" value="<%=Model.Code %>" />
                </p>
                <p>
                    <label for="Description">Description:</label>
                    <input type="text" id="Description" maxlength="100" class="textEntry" value="<%=Model.Description %>" />
                </p>
                <p>
                    <label for="AccountType">Account Type:</label>
                    <asp:DropDownList ID="AccountType" runat="server">
                    </asp:DropDownList>
                </p>
                <p>
                    <label for="AccountSign">Account Sign:</label>
                    <asp:DropDownList ID="AccountSign" runat="server">
                    </asp:DropDownList>
                </p>
            </fieldset>
            <p class="submitButton">
                <input type="button" id="AdjustmentSubmitButton" value="OK" />
            </p>
            </form>     

</asp:Content>